﻿<Window x:Class="JhVirtualKeyboard.VirtualKeyboard"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d"
    xmlns:jh="clr-namespace:JhLib;assembly=JhLib"
    xmlns:vk="clr-namespace:JhVirtualKeyboard"
    xmlns:vm="clr-namespace:JhVirtualKeyboard.ViewModels"
    x:Name="VK"
    jh:WindowSettings.SaveSize="True"
    Title="JhVirtualKeyboard" Height="330" Width="720" d:DesignHeight="300" d:DesignWidth="710"
    FontFamily="{Binding Path=DefaultFontFamily}" Background="{StaticResource dialogBackgroundBrush}" ShowInTaskbar="False" WindowStyle="ToolWindow"
    DataContext="{DynamicResource keyboardViewModel}">

    <Window.Resources>
        <SolidColorBrush x:Key="brushBlue" Color="#FF4883EF"/>
        <ImageBrush x:Key="dialogBackgroundBrush" ImageSource="/JhVirtualKeyboard;component/Images/TextureR40x40.png" Viewport="0,0,40,40" ViewportUnits="Absolute" Stretch="None" AlignmentX="Left" AlignmentY="Top" TileMode="Tile" />
        <jh:BoolToVisibleVCollapsedConverter x:Key="boolToVisibleConv" />
        <jh:TextToVisibleConverter x:Key="textToVisibleConv" />
        <vk:CapsLockToTextConverter x:Key="capsLockToTextConverter" />
        <vk:ShiftLockToTextConverter x:Key="shiftLockToTextConverter" />
        <vk:WhichKBLayoutToStringConverter x:Key="kbConverter" />
        <vk:BoolToBoldConverter x:Key="boolToBoldConv" />
        <ObjectDataProvider x:Key="keyboardViewModel" ObjectType="{x:Type vm:KeyboardViewModel}" MethodName="get_Instance" />
    </Window.Resources>

    <Grid Name="LayoutRoot" Margin="6,2,6,0">
        <Grid.Resources>
            <DataTemplate DataType="{x:Type vm:KeyModelWithThreeGlyphs}">
                <TextBlock DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                           FontFamily="{Binding Path=KB.KeycapFontFamily, Source={StaticResource keyboardViewModel}}"
                           FontSize="{Binding KB.FontSizeForStackedGlyphs, Source={StaticResource keyboardViewModel}}" Margin="0" >
                    <Run FontWeight="{Binding Path=Content.IsInUpperGlyphMode, Converter={StaticResource boolToBoldConv}}"
                        Text="{Binding Content.TextShifted, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                        ToolTip="{Binding Content.ShiftedToolTip, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
                    <Run FontWeight="{Binding Source={StaticResource keyboardViewModel}, Path=IsInNormalState, Converter={StaticResource boolToBoldConv}}"
                         Text="{Binding Content.TextUnshiftedNL, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                         ToolTip="{Binding Content.UnshiftedToolTip, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
                    <Run FontWeight="{Binding Source={StaticResource keyboardViewModel}, Path=IsInAltGrState, Converter={StaticResource boolToBoldConv}}"
                         Foreground="{Binding Source={StaticResource keyboardViewModel}, Path=ColorForAltGr}"
                         Text="{Binding Content.TextAltGr, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
                         ToolTip="{Binding Content.AltGrToolTip, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
                </TextBlock>
            </DataTemplate>
            <DataTemplate DataType="{x:Type vm:KeyModelWithTwoGlyphs}">
                <TextBlock DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                           FontFamily="{Binding Path=KB.KeycapFontFamily, Source={StaticResource keyboardViewModel}}"
                           FontSize="{Binding KB.FontSizeForStackedGlyphs, Source={StaticResource keyboardViewModel}}" Margin="0" >
                    <Run FontWeight="{Binding Path=Content.IsInUpperGlyphMode, Converter={StaticResource boolToBoldConv}}"
                        Text="{Binding Content.TextShifted, Mode=OneWay}"
                        ToolTip="{Binding Content.ShiftedToolTip, Mode=OneWay}" />
                    <Run FontWeight="{Binding Source={StaticResource keyboardViewModel}, Path=IsInNormalState, Converter={StaticResource boolToBoldConv}}"
                         Text="{Binding Content.TextUnshiftedNL, Mode=OneWay}"
                         ToolTip="{Binding Content.UnshiftedToolTip, Mode=OneWay}" />
                </TextBlock>
            </DataTemplate>
            <DataTemplate DataType="{x:Type vm:KeyModel}">
                <TextBlock DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}"
                           FontFamily="{Binding Path=KB.KeycapFontFamily, Source={StaticResource keyboardViewModel}}"
                           FontSize="{Binding KB.FontSizeForSingleGlyphs, Source={StaticResource keyboardViewModel}}" Margin="0" >
                    <Run Text="{Binding Content.Text, Mode=OneWay}"
                         ToolTip="{Binding Content.ToolTip, Mode=OneWay}" />
                </TextBlock>
            </DataTemplate>
            <Style TargetType="Button">
                <Setter Property="Command" Value="{Binding KeyPressedCommand}" />
                <Setter Property="CommandParameter" Value="{Binding Path=Content, RelativeSource={RelativeSource Self}}" />
                <Setter Property="FontSize" Value="{Binding DefaultFontSize}"/>
                <Setter Property="Height" Value="Auto"/>
                <Setter Property="Width" Value="Auto"/>
                <Style.Triggers>
                    <Trigger Property="IsPressed" Value="False">
                        <!-- This is here because we're setting it slightly differently when the button is being pressed. -->
                        <Setter Property="Margin" Value="0,0,2,1"/>
                        <Setter Property="Effect">
                            <Setter.Value>
                                <DropShadowEffect Direction="315" Opacity="0.7"/>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                    <Trigger Property="IsPressed" Value="True">
                        <Setter Property="Foreground" Value="{StaticResource brushBlue}"/>
                        <!-- Shift the button downward and to the right slightly, to give the affect of being pushed inward. -->
                        <Setter Property="Margin" Value="2,1,0,0"/>
                        <Setter Property="Effect">
                            <Setter.Value>
                                <DropShadowEffect Direction="135" Opacity="0.5" ShadowDepth="2"/>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
            </Style>
            <Style x:Key="specialKeyStyle" TargetType="Button">
                <Setter Property="Control.Background" Value="#716F64" />
                <Setter Property="Control.Foreground" Value="White" />
                <Setter Property="Button.FontSize" Value="12"/>
                <Setter Property="Button.Margin" Value="0,0,2,1"/>
                <Style.Triggers>
                    <Trigger Property="Control.IsMouseOver" Value="True">
                        <Setter Property="Control.Foreground" Value="Blue"/>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </Grid.Resources>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <!-- The topmost row - digits and symbols (KeysRow1) -->
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="4*"/>
            </Grid.ColumnDefinitions>
            <Button Name="btnVK_Oem3" Content="{Binding KB.VK_Oem3}" Grid.Column="0" />
            <Button Name="btnVK_1" Content="{Binding KB.VK_1}" Grid.Column="1" />
            <Button Name="btnVK_2" Content="{Binding KB.VK_2}" Grid.Column="2" />
            <Button Name="btnVK_3" Content="{Binding KB.VK_3}" Grid.Column="3" />
            <Button Name="btnVK_4" Content="{Binding KB.VK_4}" Grid.Column="4" />
            <Button Name="btnVK_5" Content="{Binding KB.VK_5}" Grid.Column="5" />
            <Button Name="btnVK_6" Content="{Binding KB.VK_6}" Grid.Column="6" />
            <Button Name="btnVK_7" Content="{Binding KB.VK_7}" Grid.Column="7" />
            <Button Name="btnVK_8" Content="{Binding KB.VK_8}" Grid.Column="8" />
            <Button Name="btnVK_9" Content="{Binding KB.VK_9}" Grid.Column="9" />
            <Button Name="btnVK_0" Content="{Binding KB.VK_0}" Grid.Column="10" />
            <Button Name="btnVK_OemMinus" Content="{Binding KB.VK_OemMinus}" Grid.Column="11" />
            <Button Name="btnVK_OemPlus" Content="{Binding KB.VK_OemPlus}" Grid.Column="12" />
            <Button Name="btnBackspace" Command="{Binding BackspaceCommand}" Grid.Column="13" Style="{StaticResource specialKeyStyle}" ToolTip="backspace" Padding="0">
                <Button.Content>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock x:Name="lblBackspace" Text="BS" VerticalAlignment="Top" />
                        <Canvas x:Name="arrow30" Margin="0,0,0,0" VerticalAlignment="Bottom" HorizontalAlignment="Stretch">
                            <Path x:Name="pathLeftArrow" Width="38" Height="9" Canvas.Left="-15" Canvas.Top="-1" Stretch="Fill" Fill="#FFF2F2F2" Data="F1 M 0.684,18.073 L12.790,5.968 L12.790,14.385 L54.794,14.385 L54.794,21.761 L12.790,21.761 L12.790,30.178 Z "/>
                        </Canvas>
                    </Grid>
                </Button.Content>
            </Button>

        </Grid>
        <!-- The 2nd row, upper-most letters (KeysRow2) -->
        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="4*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
            </Grid.ColumnDefinitions>
            <Button Name="btnTab" Command="{Binding KeyPressedCommand}" CommandParameter="{Binding TabKey}" Grid.Column="0" Style="{StaticResource specialKeyStyle}">Tab</Button>
            <Button Name="btnVK_Q" Content="{Binding KB.VK_Q}" Grid.Column="1" />
            <Button Name="btnVK_W" Content="{Binding KB.VK_W}" Grid.Column="2" />
            <Button Name="btnVK_E" Content="{Binding KB.VK_E}" Grid.Column="3" />
            <Button Name="btnVK_R" Content="{Binding KB.VK_R}" Grid.Column="4" />
            <Button Name="btnVK_T" Content="{Binding KB.VK_T}" Grid.Column="5" />
            <Button Name="btnVK_Y" Content="{Binding KB.VK_Y}" Grid.Column="6" />
            <Button Name="btnVK_U" Content="{Binding KB.VK_U}" Grid.Column="7" />
            <Button Name="btnVK_I" Content="{Binding KB.VK_I}" Grid.Column="8" />
            <Button Name="btnVK_O" Content="{Binding KB.VK_O}" Grid.Column="9" />
            <Button Name="btnVK_P" Content="{Binding KB.VK_P}" Grid.Column="10" />
            <Button Name="btnVK_OemOpenBrackets" Content="{Binding KB.VK_OemOpenBrackets}" Grid.Column="11" />
            <Button Name="btnVK_Oem6" Content="{Binding KB.VK_Oem6}" Grid.Column="12" />
            <Button Name="btnVK_Oem5" Content="{Binding KB.VK_Oem5}" Grid.Column="13" />
        </Grid>
        <!-- The 3rd row, middle letters (KeysRow3) -->
        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="5*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="5*"/>
            </Grid.ColumnDefinitions>
            <Button Name="btnCapsLock" Command="{Binding CapsLockCommand}" Grid.Column="0" Style="{StaticResource specialKeyStyle}">
                <Button.Content>
                    <StackPanel>
                        <TextBlock HorizontalAlignment="Center" Text="{Binding IsCapsLock, Converter={StaticResource capsLockToTextConverter}}" />
                        <Line Stroke="Yellow" X1="0" Y1="6" X2="50" Y2="6" Visibility="{Binding Path=IsCapsLock, Converter={StaticResource boolToVisibleConv}}" />
                    </StackPanel>
                </Button.Content>
            </Button>
            <Button Name="btnVK_A" Content="{Binding KB.VK_A}" Grid.Column="1" />
            <Button Name="btnVK_S" Content="{Binding KB.VK_S}" Grid.Column="2" />
            <Button Name="btnVK_D" Content="{Binding KB.VK_D}" Grid.Column="3" />
            <Button Name="btnVK_F" Content="{Binding KB.VK_F}" Grid.Column="4" />
            <Button Name="btnVK_G" Content="{Binding KB.VK_G}" Grid.Column="5" />
            <Button Name="btnVK_H" Content="{Binding KB.VK_H}" Grid.Column="6" />
            <Button Name="btnVK_J" Content="{Binding KB.VK_J}" Grid.Column="7" />
            <Button Name="btnVK_K" Content="{Binding KB.VK_K}" Grid.Column="8" />
            <Button Name="btnVK_L" Content="{Binding KB.VK_L}" Grid.Column="9" />
            <Button Name="btnVK_Oem1" Content="{Binding KB.VK_Oem1}" Grid.Column="10" />
            <Button Name="btnVK_Oem7" Content="{Binding KB.VK_Oem7}" Grid.Column="11" />
            <Button Name="btnEnter" Command="{Binding KeyPressedCommand}" CommandParameter="{Binding EnterKey}" Grid.Column="12" Style="{StaticResource specialKeyStyle}">Enter</Button>
        </Grid>
        <!-- The 4th row, bottom-most keys (KeysRow4) -->
        <Grid Grid.Row="3">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="6.5*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="3*"/>
                <ColumnDefinition Width="6.5*"/>
            </Grid.ColumnDefinitions>
            <Button Name="btnShift_Left" Command="{Binding ShiftCommand}" FontWeight="{Binding Path=ShiftKey.FontWeight}" 
                Style="{StaticResource specialKeyStyle}" ToolTip="{Binding Path=ShiftKey.ToolTip}">
                <Button.Content>
                    <StackPanel>
                        <TextBlock HorizontalAlignment="Center" Text="{Binding IsShiftLock, Converter={StaticResource shiftLockToTextConverter}}" />
                        <Line Stroke="Yellow" X1="0" Y1="6" X2="50" Y2="6" Visibility="{Binding Path=IsShiftLock, Converter={StaticResource boolToVisibleConv}}" />
                    </StackPanel>
                </Button.Content>
            </Button>
            <Button Name="btnVK_Z" Content="{Binding KB.VK_Z}" Grid.Column="1" />
            <Button Name="btnVK_X" Content="{Binding KB.VK_X}" Grid.Column="2" />
            <Button Name="btnVK_C" Content="{Binding KB.VK_C}" Grid.Column="3" />
            <Button Name="btnVK_V" Content="{Binding KB.VK_V}" Grid.Column="4" />
            <Button Name="btnVK_B" Content="{Binding KB.VK_B}" Grid.Column="5" />
            <Button Name="btnVK_N" Content="{Binding KB.VK_N}" Grid.Column="6" />
            <Button Name="btnVK_M" Content="{Binding KB.VK_M}" Grid.Column="7" />
            <Button Name="btnVK_OemComma" Content="{Binding KB.VK_OemComma}" Grid.Column="8" />
            <Button Name="btnVK_OemPeriod" Content="{Binding KB.VK_OemPeriod}" Grid.Column="9" />
            <Button Name="btnVK_OemQuestion" Content="{Binding KB.VK_OemQuestion}" Grid.Column="10" />
            <Button Name="btnShift_Right" Command="{Binding ShiftCommand}" FontWeight="{Binding Path=ShiftKey.FontWeight}"
                Grid.Column="11" Style="{StaticResource specialKeyStyle}" ToolTip="{Binding Path=ShiftKey.ToolTip}">
                <Button.Content>
                    <StackPanel>
                        <TextBlock HorizontalAlignment="Center" Text="{Binding IsShiftLock, Converter={StaticResource shiftLockToTextConverter}}" />
                        <Line Stroke="Yellow" X1="0" Y1="6" X2="50" Y2="6" Visibility="{Binding Path=IsShiftLock, Converter={StaticResource boolToVisibleConv}}" />
                    </StackPanel>
                </Button.Content>
            </Button>
        </Grid>
        <!-- The 5th row, with Ctrl, Alt and Spacebar -->
        <Grid Grid.Row="4" Margin="0,2,0,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="10*"/>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="21*"/>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="4*"/>
                <ColumnDefinition Width="6*"/>
            </Grid.ColumnDefinitions>
            <Button Name="btnVK_SPACE" Command="{Binding KeyPressedCommand}" CommandParameter="{Binding VK_SPACE}" Content="Space" Grid.Column="2" />
            <Button Name="btnAlt_Right" Command="{Binding AltStateCommand}" FontSize="14" FontWeight="{Binding Path=Alt_Right.FontWeight}" 
                Foreground="{Binding ColorForAltGr}" Grid.Column="4" Style="{StaticResource specialKeyStyle}" ToolTip="{Binding Path=Alt_Right.ToolTip}" 
                Visibility="{Binding Path=KB.IsAltGrKeyUsed, Converter={StaticResource boolToVisibleConv}}">
                <Button.Content>
                    <StackPanel>
                        <TextBlock HorizontalAlignment="Center" Text="{Binding Path=Alt_Right.Text}" />
                        <Line Stroke="Yellow" X1="0" Y1="6" X2="50" Y2="6" Visibility="{Binding Path=IsInAltGrState, Converter={StaticResource boolToVisibleConv}}" />
                    </StackPanel>
                </Button.Content>
            </Button>
            <CheckBox Name="ckbxFlowDirection" Content="Left-to-Right" Grid.Column="5" HorizontalAlignment="Right" IsChecked="{Binding Path=IsForcingLeftToRight}" 
                      ToolTip="FlowDirection is RightToLeft. Put a checkmark here to force it to insert characters LeftToRight." VerticalAlignment="Center"
                      Visibility="{Binding Path=IsFlowDirectionLeftToRight, Converter={StaticResource boolToVisibleConv}}" />
        </Grid>
        <!-- The special-characters area lives within the 5th and 6th rows -->
        <StackPanel Name="SanskritSpecials" Grid.Row="5" Margin="0,2,0,1" Orientation="Horizontal"
                    Visibility="{Binding IsSanskrit, Converter={StaticResource boolToVisibleConv}}">
            <StackPanel.Resources>
                <Style TargetType="Button">
                    <Setter Property="Command" Value="{Binding KeyPressedCommand}"/>
                    <Setter Property="FontSize" Value="18"/>
                    <Setter Property="Height" Value="29"/>
                    <Setter Property="Margin" Value="1,0,0,0"/>
                    <Setter Property="Width" Value="32"/>
                </Style>
            </StackPanel.Resources>
            <Button Name="btnSectionMarkSanskrit" CommandParameter="&#x0936;&#x094D;&#x0930;" ToolTip="Combination of &#x0936;&#x094D; and &#x0930;" Width="25">&#x0936;&#x094D;&#x0930;</Button>
            <Button Name="btnParagraphSanskrit" CommandParameter="&#x0965;" FontSize="22" Padding="0,-3,0,0" ToolTip="Double Danda" Width="21">&#x0965;</Button>
            <Button Name="btnEmDashSanskrit" CommandParameter="&#x200C;" ToolTip="Zero width non-joiner for separating combination of complex letters" Width="20">&#x200C;</Button>
            <Button Name="btnOpeningSglQuoteSanskrit" CommandParameter="&#x0901;" FontSize="22" Padding="0" ToolTip="Chandra Bindhu" Width="24">&#x0901;</Button>
            <Button Name="btnClosingSglQuoteSanskrit" CommandParameter="&#x0902;" FontSize="22" Padding="0" ToolTip="Anusvara" Width="24">&#x0902;</Button>
            <Button Name="btnOpeningDblQuoteSanskrit" CommandParameter="&#x201C;" FontSize="24" Padding="0,-3,0,0" ToolTip="opening double-quote" Width="20">&#x201C;</Button>
            <Button Name="btnClosingDblQuoteSanskrit" CommandParameter="&#x201D;" FontSize="24" Padding="0,-3,0,0" ToolTip="closing double-quote" Width="20">&#x201D;</Button>
            <Button Name="btnRegisteredSanskrit" CommandParameter="&#x0950;" Padding="0" ToolTip="">&#x0950;</Button>
            <Button Name="btnTrademarkSanskrit" CommandParameter="&#x090C;" Padding="0" ToolTip="Letter L with RRi" Width="23">&#x090C;</Button>
            <Button Name="btnCopyrightSanskrit" CommandParameter="&#x0961;" Padding="0,-1,0,1" ToolTip="Letter L with RRI">&#x0961;</Button>
            <Button Name="btnHalfSanskrit" CommandParameter="&#x0962;" FontSize="14" Padding="0,-1,0,1" ToolTip="Subset L with RRi" Width="24">&#x0962;</Button>
            <Button Name="btnQuarterSanskrit" CommandParameter="&#x0963;" Padding="0,-1,0,1" ToolTip="Subset L with RRI" Width="22">&#x0963;</Button>
            <Button Name="btnMicroSanskrit" CommandParameter="&#2325;&#2381;&#2359;" Padding="0,0,0,1" ToolTip="&#2325;&#2381; and &#2359;" Width="24">&#2325;&#2381;&#2359;</Button>
        </StackPanel>
        <StackPanel Name="TamilSpecials" Grid.Row="5" Margin="0,2,0,1" Orientation="Horizontal"
                    Visibility="{Binding IsTamil, Converter={StaticResource boolToVisibleConv}}">
            <StackPanel.Resources>
                <Style TargetType="Button">
                    <Setter Property="Command" Value="{Binding KeyPressedCommand}"/>
                    <Setter Property="FontSize" Value="18"/>
                    <Setter Property="Height" Value="24"/>
                    <Setter Property="Margin" Value="1,0,1,0"/>
                    <Setter Property="Padding" Value="0,-7,0,0"/>
                    <Setter Property="Width" Value="32"/>
                    <Setter Property="Effect">
                        <Setter.Value>
                            <DropShadowEffect Direction="315" Opacity="0.7"/>
                        </Setter.Value>
                    </Setter>
                    <Style.Triggers>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource brushBlue}"/>
                            <!-- Shift the button downward and to the right slightly, to give the affect of being pushed inward. -->
                            <Setter Property="Margin" Value="2,1,0,0"/>
                            <Setter Property="Effect">
                                <Setter.Value>
                                    <DropShadowEffect Direction="135" Opacity="0.5" ShadowDepth="2"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </StackPanel.Resources>
            <Button Name="btnSectionMarkTamil" CommandParameter="&#x0BB7;" ToolTip="sha">&#x0BB7;</Button>
            <Button Name="btnParagraphTamil" CommandParameter="&#x0BB8;" ToolTip="sa">&#x0BB8;</Button>
            <Button Name="btnEmDashTamil" CommandParameter="&#x0BB8;&#x0BCD;&#x0BB0;&#x0BC0;" ToolTip="Shri">&#x0BB8;&#x0BCD;&#x0BB0;&#x0BC0;</Button>
            <Button Name="btnOpeningSglQuoteTamil" CommandParameter="&#x0B95;&#x0BCD;&#x0BB7;" ToolTip="ksha">&#x0B95;&#x0BCD;&#x0BB7;</Button>
            <Button Name="btnClosingSglQuoteTamil" CommandParameter="&#x0BB9;" ToolTip="ha">&#x0BB9;</Button>
            <Button Name="btnOpeningDblQuoteTamil" CommandParameter="&#x201C;" FontSize="24" Padding="0,-3,0,0" ToolTip="opening double-quote">&#x201C;</Button>
            <Button Name="btnClosingDblQuoteTamil" CommandParameter="&#x201D;" FontSize="24" Padding="0,-3,0,0" ToolTip="closing double-quote">&#x201D;</Button>
        </StackPanel>
        <Grid Name="gridSpecialCharacters" Grid.Row="4" Grid.RowSpan="2" Margin="0,2,0,0"
              Visibility="{Binding IsDefaultSpecialCharacters, Converter={StaticResource boolToVisibleConv}}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.Resources>
                <Style TargetType="Button">
                    <Setter Property="Command" Value="{Binding KeyPressedCommand}"/>
                    <Setter Property="FontFamily" Value="Bitstream Cyberbase, Roman" />
                    <Setter Property="FontSize" Value="18"/>
                    <Setter Property="Height" Value="23"/>
                    <Setter Property="Margin" Value="1,0,2,1"/>
                    <Setter Property="Padding" Value="0"/>
                    <Setter Property="Width" Value="19"/>
                    <Setter Property="Effect">
                        <Setter.Value>
                            <DropShadowEffect Direction="315" Opacity="0.7"/>
                        </Setter.Value>
                    </Setter>
                    <Style.Triggers>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource brushBlue}"/>
                            <!-- Shift the button downward and to the right slightly, to give the affect of being pushed inward. -->
                            <Setter Property="Margin" Value="2,1,0,0"/>
                            <Setter Property="Effect">
                                <Setter.Value>
                                    <DropShadowEffect Direction="135" Opacity="0.5" ShadowDepth="2"/>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Grid.Resources>
            <Button Name="btnOpeningSglQuote" CommandParameter="&#x2018;" FontFamily="Arial Unicode MS" FontSize="24" Padding="0,-3,0,0" ToolTip="opening single-quote">&#x2018;</Button>
            <Button Name="btnClosingSglQuote" CommandParameter="&#x2019;" FontFamily="Arial Unicode MS" FontSize="24" Grid.Column="1" Padding="0,-3,0,0" ToolTip="closing single-quote">&#x2019;</Button>
            <Button Name="btnSectionMark" CommandParameter="&#x00A7;" Grid.Column="2" Height="24" Margin="6,0,2,1" ToolTip="Section sign, or signum sectionis" Width="25">&#x00A7;</Button>
            <Button Name="btnParagraph" CommandParameter="&#x00B6;" Grid.Column="3" ToolTip="B6 Paragraph mark, or pilcrow">&#x00B6;</Button>
            <Button Name="btnMicro" CommandParameter="&#x00B5;" FontFamily="Arial Unicode MS" FontSize="14" Grid.Column="4" Grid.Row="0" Padding="0,-4,0,1" ToolTip="B5 Micro mu symbol">&#x00B5;</Button>
            <Button Name="btnOpeningDblQuote" CommandParameter="&#x201C;" FontFamily="Arial Unicode MS" FontSize="24" Grid.Row="1" Padding="0,-3,0,0" ToolTip="opening double-quote">&#x201C;</Button>
            <Button Name="btnClosingDblQuote" CommandParameter="&#x201D;" FontFamily="Arial Unicode MS" FontSize="24" Grid.Column="1" Grid.Row="1" Padding="0,-3,0,0" ToolTip="closing double-quote">&#x201D;</Button>
            <Button Name="btnRegistered" CommandParameter="&#x00AE;" FontFamily="Arial Unicode MS" Grid.Column="2" Grid.Row="1" Height="25" Padding="0,-2,0,0" ToolTip="AE Registered sign" Width="25">&#x00AE;</Button>
            <Button Name="btnTrademark" CommandParameter="&#x2122;" FontFamily="Arial Unicode MS" Grid.Column="3" Grid.Row="1" Height="25" Padding="0,1,0,0" ToolTip="2122 Trademark sign" Width="23">&#x2122;</Button>
            <Button Name="btnCopyright" CommandParameter="&#x00A9;" FontFamily="Arial Unicode MS" Grid.Column="4" Grid.Row="1" Height="25" Padding="0,-1,0,1" ToolTip="A9 Copyright sign" Width="23">&#x00A9;</Button>
            <Button Name="btnHalf" CommandParameter="&#x00BD;" FontFamily="Arial Unicode MS" FontSize="14" Grid.Row="2" Padding="0,-1,0,1" ToolTip="BD Vulgar fraction one half" Width="21">&#x00BD;</Button>
            <Button Name="btnQuarter" CommandParameter="&#x00BC;" FontFamily="Arial Unicode MS" FontSize="14" Grid.Column="1" Grid.Row="2" Padding="0,-1,0,0" ToolTip="BC Vulgar fraction one fourth" Width="21">&#x00BC;</Button>
            <Button Name="btnEmDash" CommandParameter="&#x2014;" Grid.Column="2" Grid.Row="2" ToolTip="EM-Dash" Width="25">&#8212;</Button>
        </Grid>
        <!-- The 6th row which is at the bottom, with layout-selector and the Close button -->
        <Grid Grid.Row="5" Margin="0,5,3,2" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <TextBox Name="txtStatus" Grid.Column="1" IsReadOnly="True" Background="LightGray" Height="21" Text="{Binding Path=StatusText}" Visibility="{Binding Path=StatusText, Converter={StaticResource textToVisibleConv}}" HorizontalAlignment="Center" />
            <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Name="btnHelp" Background="Transparent" BorderBrush="Transparent" BorderThickness="0" Click="btnHelp_Click" Focusable="False" HorizontalAlignment="Center" Margin="5,1" Visibility="{Binding Path=IsHelpButtonVisible, Converter={StaticResource boolToVisibleConv}}">
                    <Image Focusable="True" HorizontalAlignment="Center" SnapsToDevicePixels="True" Source="/JhVirtualKeyboard;component/images/Q13x15.gif" Stretch="None" ToolTip="Click this to see a help-panel." UseLayoutRounding="True" VerticalAlignment="Center" />
                </Button>
                <ComboBox Name="cbKeyboardLayout" ItemsSource="{Binding AvailableKeyboardLayouts, Mode=OneWay}" 
                    HorizontalAlignment="Right" Margin="0,0,20,0"
                    SelectedValue="{Binding Path=SelectedKeyboardLayout, Mode=TwoWay, Converter={StaticResource kbConverter}, FallbackValue=English}"
                    VerticalAlignment="Center" Width="120" />
                <Button Name="btnDismiss" Click="btnDismiss_Click" Height="24" HorizontalAlignment="Right" Style="{x:Null}" Width="60">Close</Button>
            </StackPanel>
        </Grid>
    </Grid>
</Window>
